/**
 * 
 */
package wangjg.commons.character;

import java.text.DecimalFormat;

/**
 * @author wangjg
 *
 */
public class NumberFormat {
	private static final int K = 1024;
	private static final int M = K*K;
	private static final int G = M*K;
	
	public static String getFileSize(long size){
		if(size>G){
			return (size/G)+"G";
		}else if(size>M){
			return (size/M)+"M";
		}else if(size>K){
			return (size/K)+"K";
		}else{
			return size+"B";
		}
	}
	
	public static String getPlainString(double n){
		DecimalFormat df = new DecimalFormat("0.##");
		Double d = new Double(n);
		String str = df.format(d);
		return str;
	}
	
}
